<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: LQ
  Date: 2021/5/19
  Time: 19:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="/jQuery/jquery-3.4.1.min.js"></script>
    <style>
        .content_div{

            float: left;
            background-color: cadetblue;
        }

        .functionBtn{
            float: left;
            background-color: #33b86c;
        }
    </style>
</head>
<body>
<div>
    <jsp:include page="main.jsp"/>
</div>

<div style="margin-left: 30%;margin-top: 1%">
    <table border="1px" class="content_div">
        <tr>
            <td>文章标题</td>
            <td>发布时间</td>
            <td>浏览量</td>
            <td>所属分类</td>
            <td>发布状态</td>
            <td>操作</td>
        </tr>

        <c:forEach items="${requestScope.articleList}" var="article">
            <tr>
                <td>${article.articleName}</td>
                <td>${article.articleInsertTime}</td>
                <td>${article.browseNum}</td>
                <td>
                    <c:forEach items="${requestScope.categoryList}" var="category">
                        <c:if test="${article.articleCategory == category.categoryId}">
                            ${category.categoryName}
                        </c:if>
                    </c:forEach>
                </td>
                <td>
                    <c:choose>
                        <c:when test="${article.isDraft == 1}">
                            草稿
                        </c:when>

                        <c:otherwise>
                            已发布
                        </c:otherwise>
                    </c:choose>
                </td>
                <td style=" width:130px">
                    <form action="/getEditArticle?aId=${article.articleId}" method="post">
                        <button type="submit" class="functionBtn">编辑</button>
                    </form>

                    <form action="/deleteArticle?articleId=${article.articleId}" method="post">
                        <button type="submit" class="functionBtn" style="background-color: coral">删除</button>
                    </form>

                    <form action="/preview?aId=${article.articleId}" method="post">
                        <button type="submit" class="functionBtn">预览</button>
                    </form>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>

</body>
</html>
